chrschu
07/21/2023, 7:44 PMchrschu
07/21/2023, 7:44 PMfun getSubjectsForRelation(
objType: String,
subject: String,
subjectId: String,
permission: String,
pagination: SpiceDbPagination? = null
): PaginatedResult<String> {
val request = LookupResourcesRequest.newBuilder()
.setSubject(buildSubjectRef(subject, subjectId))
.setPermission(permission)
.setResourceObjectType(objType)
.apply {
if (pagination != null) {
// the first page has a null cursor
if (pagination.cursor != null) {
optionalCursor = Cursor.newBuilder().setToken(pagination.cursor).build()
}
optionalLimit = pagination.limit
}
}
.build()
val response = permissionsService.lookupResources(request)
var results = mutableListOf<String>()
var cursor: Cursor? = null
while (response.hasNext()) {
val next = response.next()
cursor = next.afterResultCursor
results.add(next.resourceObjectId)
}
return PaginatedResult(
results,
SpiceDbPagination(cursor?.token, pagination?.limit ?: results.size)
)
}Joey
07/21/2023, 8:03 PMJoey
07/21/2023, 8:03 PMJoey
07/21/2023, 8:03 PMchrschu
07/21/2023, 9:25 PMchrschu
07/21/2023, 9:25 PMJoey
07/21/2023, 9:27 PMJoey
07/21/2023, 9:27 PMJoey
07/21/2023, 9:27 PMJoey
07/21/2023, 9:27 PMJoey
07/21/2023, 9:27 PMJoey
07/21/2023, 9:27 PMJoey
07/21/2023, 9:27 PMJoey
07/21/2023, 9:28 PMchrschu
07/21/2023, 9:28 PMchrschu
07/21/2023, 9:28 PMchrschu
07/21/2023, 9:28 PMJoey
07/21/2023, 9:28 PMJoey
07/21/2023, 9:28 PMJoey
07/21/2023, 9:28 PMchrschu
07/21/2023, 9:29 PMchrschu
07/21/2023, 9:30 PMJoey
07/21/2023, 9:31 PMJoey
07/21/2023, 9:31 PMJoey
07/21/2023, 9:31 PMdefinition user {}
definition resource {
relation viewer: user
relation editor: user
permission view = viewer + editor
}Joey
07/21/2023, 9:31 PMviewer and editor role (for some reason)Joey
07/21/2023, 9:31 PMviewJoey
07/21/2023, 9:31 PMJoey
07/21/2023, 9:31 PMJoey
07/21/2023, 9:31 PMJoey
07/21/2023, 9:32 PMchrschu
07/21/2023, 9:32 PMJoey
07/21/2023, 9:32 PMJoey
07/21/2023, 9:32 PMchrschu
07/21/2023, 9:32 PMJoey
07/21/2023, 9:32 PMchrschu
07/21/2023, 9:32 PMJoey
07/21/2023, 9:32 PMchrschu
07/21/2023, 9:33 PMJoey
07/21/2023, 9:33 PMJoey
07/21/2023, 9:33 PMJoey
07/21/2023, 9:33 PMchrschu
07/21/2023, 9:33 PMJoey
07/21/2023, 9:34 PMlatest tagJoey
07/21/2023, 9:34 PMJoey
07/21/2023, 9:34 PMJoey
07/21/2023, 9:34 PMJoey
07/21/2023, 9:34 PM